<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Core/js/ext/webuploader/js/webuploader.js"></script>
<link href="__PUBLIC__/Core/js/ext/webuploader/css/webuploader.css" type="text/css" rel="stylesheet">
<span id="web_uploader_wrapper_{$id}">{$config['text']}</span>

<input id="web_uploader_input_{$id}" name="{$name}" type="hidden" value="{$value}" event-args="{$args}" event-node="uploadinput">
<div id="web_uploader_picture_list_{$id}" class="web_uploader_picture_list">
    {$img}
</div>
<script>
    $(function () {
        var id = "#web_uploader_wrapper_{$id}";
        var uploader_{$id}  = WebUploader.create({
            // swf文件路径
            swf: 'Uploader.swf',
            // 文件接收服务端。
            server: U('Core/File/uploadPicture'),
            fileNumLimit: 5,
            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: {'id': id, 'multi': false}
        });
        uploader_{$id}.on('fileQueued', function (file) {
            uploader_{$id}.upload();
            $("#web_uploader_file_name_{$id}").text('正在上传...');
        });

        /*上传成功*/
        uploader_{$id}.on('uploadSuccess', function (file, ret) {
            if (ret.status == 0) {
                $("#web_uploader_file_name_{$id}").text(ret.info);
            } else {
                $('#web_uploader_input_{$id}').focus();
                $('#web_uploader_input_{$id}').val(ret.data.file.id);
                $('#web_uploader_input_{$id}').blur();

                $("#web_uploader_picture_list_{$id}").html('<img src="' + ret.data.file.path + '"/>');
            }
        });
    });

</script>